import { asyncRoutes, constantRoutes } from '@/router'
const state = {
  routes: constantRoutes
}
const mutations = {
  setRoutes(state, data) {
    state.routes = [...constantRoutes, ...data]
  }
}
const actions = {
  filterRoutes({ commit }, menus) {
    console.log(menus)
    // 筛选相同的路由
    const otherRoutes = asyncRoutes.filter((item) => {
      // menus传入的用户路由信息
      if (menus.includes(item.children[0].name)) {
        return true
      } else {
        return false
      }
    })
    console.log(otherRoutes)
    commit('setRoutes', otherRoutes)
    return otherRoutes
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
